package com.fita.entity.order;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.format.annotation.DateTimeFormat;
import com.demo2do.core.format.DecimalFormat;
import com.demo2do.core.format.PersistentFormat;
import com.demo2do.core.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fita.entity.agent.Agent;
import com.fita.entity.principal.Principal;
import com.fita.entity.wallet.DistributionRewardRecord;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 订单
 * 
 * @author 宋剑宏
 *
 */
@Entity
@Table(name = "orders")
@PersistentFormat
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class Order {

    @Id
    @GeneratedValue
    private Long id;

    /** 订单号 */
    private String code;
    
    /**
     * alamo 系统订单号
     */
    private String alamoCode;

    private String country; // 国家

    private String brand; // 品牌

    private String vehicleType; // 车型

    private String vehicleBrand; // 车型
    
    private String vehiclePicture; // 车型
    
    private String pickupLocationName; // 车型

    private String pickupLocation; // 取车地点
    
    private String returnLocationName; // 车型

    private String returnLocation; // 还车地点

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date pickupDate; // 取车时间

    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date returnDate; // 还车时间

    /** == 客户冗余信息 == */
    private String customerPerfix;// 姓

    private String customerName; // 名

    private String customerEmail;// 电邮
    
    private String customerMobile;// 电话
    
    //用户优惠券绑定使用
    private Long userCouponId;

    
    /**
     * 订单额外详细信息
     */
    @ManyToOne(optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private OrderDetails details; // 所属订单
    
    @Enumerated(EnumType.STRING)
    private OrderPayType orderPayType;  //订单支付方式

    @DecimalFormat(scale = 100)
    private int payPrice; // 支付金额(精确到分)($)
    
    @DecimalFormat(scale = 100)
    private int actualPayPrice; // 实际支付金额(精确到分)(￥)

    @DecimalFormat(scale = 100)
    private int costPrice; // 成本价($)
    
    @DecimalFormat(scale = 100)
    private int totalAmount; // API返回价格(精确到分)($)
    
    @DecimalFormat(scale = 100)
    private int retailAmount; // 官方零售价(精确到分)(预付：￥，到付: $)
    
    /**
     * 官方零售价 美金
     */
    private BigDecimal retailDollarAmount;


    private String currencyCode; // 货币代码
    
    private BigDecimal currentExchangeRate; // 当前汇率
    
    private int agentRate; // 代理返点率
    
    private Long couponId; // 优惠券

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime; // 下单时间

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String operateEndDate; // 操作截止日期（锁定、取消、支付的截止日期）

    @Enumerated(EnumType.STRING)
    private OrderStatus status; // 订单状态

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date payTime; // 支付时间

    @Enumerated(EnumType.STRING)
    private PayType type; // 预付/到付

    @Enumerated(EnumType.STRING)
    private PayStatus payStatus; // 支付状态

    @ManyToOne( optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Agent agent; // 代理

    @DecimalFormat(scale = 100)
    private int rebate; // 代理返点

    private Boolean invoice; // 是否开票

    private String comment; // 订单备注
    
    private String pdfUrl; // 订单确认PDF

    /**
     * 代理分销记录
     */
    @ManyToOne
    private DistributionRewardRecord distributionRewardRecord;

    //发票信息记录
    /** 开票状态 */
    @Enumerated(EnumType.STRING)
    private InvoiceStatus invoiceStatus;

    /** 开票二维码地址 */
    private String invoiceQrcodeUrl;

    /** 发票保存地址 */
    private String invoicePdf;

    /** 红票保存地址 */
    private String redInvoicePdf;

    /**发票原始代码*/
    private String invoiceOriginalCode;

    /**发票原始号码*/
    private String invoiceOriginalNumber;

    /**发票抬头*/
    private String invoiceTitle;


    @Column(name = "is_disabled")
    private boolean disabled;

    /**
     * 支付图片凭证
     */
    private String payPic;

    /**
     * 标记支付操作人
     */
    @ManyToOne
    private Principal markPayOperator;

    /**
     * 标记支付时间
     */
    private Date markPayTime;

    /**
     * 取消时间
     */
    private Date cancelTime;

    /**
     * 退款时间
     */
    private Date refundTime;

    /**
     * 支付流水号
     */
    @SuppressWarnings("unused")
    private String payCode;

    /**
     * The default constructor
     */
    public Order() {
    }
    
    public Order(Agent agent,
                 String countryCode,
                 PayType payType,
                 String brand, 
                 String vehicleType,
                 String vehicleBrand,
                 String vehiclePicture,
                 String pickupLocationName,
                 String returnLocationName,
                 String pickupLocation,
                 String returnLocation,
                 Date pickupDate,
                 Date returnDate) {
        this.agent = agent;
        this.country = countryCode;
        this.brand = brand;
        this.type = payType;
        this.vehicleType = vehicleType;
        this.vehicleBrand = vehicleBrand;
        this.vehiclePicture = vehiclePicture;
        this.returnLocationName = returnLocationName;
        this.pickupLocationName = pickupLocationName;
        this.pickupLocation = pickupLocation;
        this.returnLocation = returnLocation;
        this.pickupDate = pickupDate;
        this.returnDate = returnDate;
    }

    /**
     * 见闻实际收入
     * @return
     */
    public BigDecimal getFitaActualIncome(){

        if (this.getDistributionRewardRecord() != null){
            BigDecimal cnyPayPrice = getCnyPayPrice();
            BigDecimal subtract1 = cnyPayPrice.subtract(new BigDecimal(this.getDistributionRewardRecord().getAmount()).divide(new BigDecimal(100)));
            return subtract1.setScale(2, RoundingMode.HALF_UP);
        }

        return getCnyPayPrice();
    }

    public String getStautsDesc() {
        return this.status != null ? this.status.getDescription() : StringUtils.EMPTY;
    }
    
    public String getTypeDesc() {
        return this.type != null ? this.type.getDescription() : StringUtils.EMPTY;
    }
    
    public String getPayStatusDesc() {
        return this.payStatus != null ? this.payStatus.getDescription() : StringUtils.EMPTY;
    }
    
    public Order bindDetail(OrderDetails orderDetails) {
        this.details = orderDetails;
        this.customerPerfix = orderDetails.getCustomerInfo().getSurname();
        this.customerName = orderDetails.getCustomerInfo().getName();
        this.customerEmail = orderDetails.getCustomerInfo().getEmail();
        this.customerMobile = orderDetails.getCustomerInfo().getMobile();
        return this;
    }
    
    public Order init() {
        this.code = "O" + new Date().getTime();
        this.status = OrderStatus.CREATED;
        this.payStatus = PayStatus.UNPAID;
        this.createTime = new Date();
        this.disabled = false;
        
        return this;
    }
    
    /**
     * 
     * @param totalAmount
     * @param agentRate
     * @param costPrice
     * @param payPrice
     * @param currencyCode
     * @param currentExchangeRate
     * @param retailAmount
     * @param couponId
     * @param destinationPaidUSD
     * @return
     */
    public Order generatePrice(int totalAmount, int agentRate, int costPrice,
                               int payPrice, String currencyCode, BigDecimal currentExchangeRate,
                               int retailAmount, Long couponId, BigDecimal destinationPaidUSD) {
        this.totalAmount = totalAmount;
        this.agentRate = agentRate;
        this.costPrice = costPrice;
        this.payPrice = payPrice;
        this.currencyCode = currencyCode;
        this.currentExchangeRate = currentExchangeRate;
        this.retailAmount = retailAmount;
        this.couponId = couponId;
        this.retailDollarAmount = destinationPaidUSD;
        return this;
    }
    
    /**
     * 取消预定
     * 
     * @return
     */
    public Order cancelBooking() {
		
		this.status = OrderStatus.CANCELED;
		
		return this;
	}
    
    public Order staying() {
        this.status = OrderStatus.STAYING;
        return this;
    }
    
    /**
     * 使用优惠券改变订单金额
     * @param totalAmount
     * @param couponAmount
     * @return
     */
    public Order useCouponDiscount (int totalAmount,int couponAmount ) {
    	
    	this.totalAmount = totalAmount - couponAmount;
    	
    	return this;
    }
    
    /**
     * 
     * @return
     */
    public Order paid(int amount, OrderPayType orderPayType, String payCode) {
        this.payStatus = PayStatus.PAID;
        this.status = OrderStatus.PAID;
        this.payTime = new Date();
        this.actualPayPrice = amount;
        this.orderPayType = orderPayType;
        this.payCode = payCode;
        return this;
    }
    
    /**
     * 标记已支付
     * @return
     * @throws ParseException 
     */
    public Order markPay(OrderComponent orderComponent, Principal principal) throws ParseException {
    	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	java.util.Date date=sdf.parse(orderComponent.getPayTime());
    	this.status = OrderStatus.PAID;
    	this.payStatus = PayStatus.PAID;
        this.payTime = date;
        this.orderPayType = orderComponent.getOrderPayType();
        this.actualPayPrice = orderComponent.getActualPayPrice();
        this.payPic = orderComponent.getPayPic();
        this.markPayOperator = principal;
        this.markPayTime = new Date();
        this.payCode = orderComponent.getPayCode();
        return this;
    }
    
    /**
     * 取消订单
     * @return
     */
    public Order cancelOrder() {
    	
        // 已付款 取消订单
        if (this.status.isPaid()) {
            this.status = OrderStatus.UNREFUNDED;
        }else {
            this.status = OrderStatus.CANCELED;
        }

        this.cancelTime = new Date();

        return this;
    }

    /**
    * @description 开票中状态
    * @params * @param
    * @return  void
    * @author  LZJ
    * @date  2019/9/17 18:19 *
    */
    public void createInvoice() {

        this.invoiceStatus = InvoiceStatus.CREATED;
    }

    /**
    * @description 普通发票保存到本地
    * @params * @param invoicePdfPath
    * @return  void
    * @author  LZJ
    * @date  2019/9/17 16:59 *
    */
    public void saveInvoicePath(String invoicePdfPath,String invoiceOriginalCode,String invoiceOriginalNumber,String invoiceTitle) {

        this.invoicePdf = invoicePdfPath;
        this.invoiceOriginalCode = invoiceOriginalCode;
        this.invoiceOriginalNumber = invoiceOriginalNumber;
        this.invoiceStatus = InvoiceStatus.MAKED;
        this.invoiceTitle = invoiceTitle;

    }

    /**
    * @description 红票保存到本地
    * @params * @param invoicePdfPath
    * @return  void
    * @author  LZJ
    * @date  2019/9/19 14:18 *
    */
    public void saveRedInvoicePath(String invoicePdfPath) {

        this.redInvoicePdf = invoicePdfPath;
    }

    /**
    * @description 标记为已开红票
    * @params * @param
    * @return  void
    * @author  LZJ
    * @date  2019/9/20 11:00 *
    */
    public void redMaked(){

        this.invoiceStatus = InvoiceStatus.REDMAKED;
    }

    
    /**
     * 
     * refunded
     */
    public Order refunded() {

        if (this.status.isUnRefunded()) {
            this.payStatus = PayStatus.REFUNDED;
        }
    	this.status = OrderStatus.CANCELED;

        this.refundTime = new Date();

    	return this;
    }
    
    /**
     * 
     * @return
     */
    public Order consumed() {
        this.status = OrderStatus.CONSUMED;
        return this;
    }
    
    /**
     * delete
     */
    public Order delete() {
        this.disabled = true;
        return this;
    }

    /**
     * 
     * cancel
     */
    public Order cancel() {
        this.status = OrderStatus.CANCELED;
        this.disabled = true;
        this.cancelTime = new Date();
        return this;
    }

    /**
     * 支付
     */
    public Order pay() {
        this.payStatus = PayStatus.PAID;
        this.payTime = new Date();
        this.status = OrderStatus.PAID;
        return this; 
    }
    
    /**
     * 
     * @param orderStatus
     * @return
     */
    public Order changeStatus(OrderStatus orderStatus) {
        this.status = orderStatus;
        return this;
    }
    
    /**
     * 
     * @param pdfUrl
     * @return
     */
    public Order editPdfUrl(String pdfUrl) {
        this.pdfUrl = pdfUrl;
        return this;
    }

    /**
     * 租借时长
     * @return
     */
    public int getRentDay() {

        int days = 0;

        if(this.pickupDate != null && this.returnDate !=null){
            long start = this.pickupDate.getTime();
            long end = this.returnDate.getTime();
            long times = (end - start) % (1000 * 60 *60 * 24) == 0 ?(end - start) / (1000 * 60 *60 * 24):(end - start) / (1000 * 60 *60 * 24)+1;
            days = Math.toIntExact(times);
        }
        return days;
    	//return DateUtils.daysBetween(pickupDate, returnDate);
    }

    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getDestinationPrice() {
        BigDecimal destinationPrice = new BigDecimal(this.totalAmount).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
        if(this.type.isPrepay()) {
            destinationPrice = destinationPrice.multiply(this.currentExchangeRate);
        }
        return destinationPrice;
    }
    
    /**
     * 使用优惠券支付
     * @return
     */
    @Transient
    public BigDecimal getCnyPayPrice(Integer couponAmount) {
        BigDecimal cNYPayPrice = new BigDecimal(this.payPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
        //优惠券可抵扣金额
        couponAmount = couponAmount/100;
        BigDecimal couponAmountToBigDecimal = new BigDecimal(couponAmount.toString());
        
        if(this.type.isPrepay()) {
            cNYPayPrice = cNYPayPrice.multiply(this.currentExchangeRate).setScale(0, RoundingMode.UP);

            // 加上一级代理提成
            if (this.distributionRewardRecord != null){
                cNYPayPrice = cNYPayPrice.multiply(new BigDecimal(1).add(new BigDecimal(this.getDistributionRewardRecord().getRate()).divide(new BigDecimal(100)))).setScale(0, RoundingMode.UP);
            }
        }
        //人名币支付金额减去优惠券金额
        return cNYPayPrice.subtract(couponAmountToBigDecimal);
    }
    /**
     * 
     * 二级代理提成价格
     *
     * @return
     */
    @Transient
    public BigDecimal getCnyPayPrice() {
        BigDecimal cNYPayPrice = new BigDecimal(this.payPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
        
        if(this.type.isPrepay()) {
            cNYPayPrice = cNYPayPrice.multiply(this.currentExchangeRate).setScale(0, RoundingMode.UP);
            DistributionRewardRecord dis = this.getDistributionRewardRecord();
            // 加上一级代理提成
            if (this.distributionRewardRecord.getId() != null){
                cNYPayPrice = cNYPayPrice.multiply(new BigDecimal(1).add(new BigDecimal(this.getDistributionRewardRecord().getRate()).divide(new BigDecimal(100)))).setScale(0, RoundingMode.UP);
            }
        }

        return cNYPayPrice;
    }
    
    /**
     * 一级代理不加二级代理提成金额
     * @return
     */
    @Transient
    public BigDecimal getPrimaryCnyPayPrice(){
        BigDecimal cNYPayPrice = new BigDecimal(this.payPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);

        if(this.type.isPrepay()) {
            cNYPayPrice = cNYPayPrice.multiply(this.currentExchangeRate).setScale(0, RoundingMode.UP);
        }

        return cNYPayPrice;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getAgentCommission() {
        BigDecimal agentCommission = new BigDecimal(this.totalAmount).multiply(new BigDecimal(agent.getCompany().getRate()).divide(new BigDecimal(100)))
                .divide(new BigDecimal(100));
        Integer primaryAgentRate = this.agent.getCompany().getPrimaryAgentRate();
        if (primaryAgentRate != null && primaryAgentRate > 0){
            BigDecimal divide = new BigDecimal(1).subtract(new BigDecimal(primaryAgentRate).divide(new BigDecimal(100)));
            agentCommission = agentCommission.multiply(divide);
        }
        return agentCommission.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getOrderCostPrice() {
    	BigDecimal orderCostPrice = new BigDecimal(this.costPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).multiply(this.currentExchangeRate);
		return orderCostPrice;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getOrderPayPrice() {
        
        BigDecimal orderPayPrice = new BigDecimal(this.payPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).multiply(this.currentExchangeRate);
        
        if (type.isPrepay()) {
            return orderPayPrice.setScale(0, RoundingMode.UP);
        }
        return orderPayPrice;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getOrderActualPayPrice() {
    	BigDecimal orderActualPayPrice = new BigDecimal(this.actualPayPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
    	return orderActualPayPrice;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getCnyAgentCommission() {
        return this.getAgentCommission().multiply(this.currentExchangeRate);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getCancelEndDate() {
        return org.apache.commons.lang3.time.DateUtils.addDays(this.pickupDate, -3);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getPayEndDate() {
        return org.apache.commons.lang3.time.DateUtils.addDays(this.pickupDate, -5);
    }
    
    /**
     * 获取取消预定截止时间
     * @return
     */
    @Transient
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getCancelBookingEndDate() {
        return org.apache.commons.lang3.time.DateUtils.addDays(this.pickupDate, -5);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getWechatPayEndDate() {
        return org.apache.commons.lang3.time.DateUtils.addHours(this.createTime, 2);
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getDecimalPayPrice() {
        return new BigDecimal(this.payPrice).divide(new BigDecimal(100));
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public BigDecimal getDecimalRetailAmount() {
    	
    	return new BigDecimal(this.retailAmount).divide(new BigDecimal(100));
    }
    
    @Transient
    public BigDecimal getDecimalTotalAmount() {
        return new BigDecimal(this.totalAmount).divide(new BigDecimal(100));
    }
    
    /**
     * 
     * @param exchangeRate
     * @return
     */
    @Transient
    public BigDecimal getDecimalPayPrice(BigDecimal exchangeRate) {
        return this.getDecimalPayPrice().multiply(exchangeRate);
    }
    
    /**
     * 是否可以取消订单
     * @return
     */
    @Transient
    public boolean isCouldCancelOrder() {

        // 订单已经取消 或者 订单待退款
        if (this.status.isCanceled() || this.status.isUnRefunded() || this.status.isConsumed()) {
            return false;
        }
        Date currentDate = new Date();
        if (currentDate.before(this.getCancelEndDate())) {
        	return true;
		}
        return false;
    }
    
    /**
     * 是否可以取消预定
     * @return
     */
    @Transient
    public boolean isCouldCancelBooking() {
    	
    	Date currentDate = new Date();
    	if (currentDate.before(this.getCancelBookingEndDate())) {
			return true;
		}
    	return false;
    }
    
    /**
     * 
     * @return
     */
    public String getFormatPickupDate() {
        return DateFormatUtils.format(this.pickupDate, "yyyy年MM月dd日HH:mm");
    }
    
    /**
     * 
     * @return
     */
    public String getFormatReturnDate() {
        return DateFormatUtils.format(this.returnDate, "yyyy年MM月dd日HH:mm");
    }

    /**
     * 获取核销时间
     * @return
     */
    @Transient
    @JsonIgnore
    public Date getConsumedDate(){

        return org.apache.commons.lang3.time.DateUtils.addDays(this.returnDate, 3);
    }

	/**
	 * 更新 alamo code
	 * @param confID
	 * @return
	 */
	public Order updateAlamoCode(String confID) {

		this.alamoCode = confID;
		
		return this;
	}


    /**
     * 绑定一级代理提成记录
     * @param distributionRewardRecord
     * @return
     */
    public Order bindDistributionRewardRecord(DistributionRewardRecord distributionRewardRecord) {
        this.distributionRewardRecord = distributionRewardRecord;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the alamoCode
     */
    public String getAlamoCode() {
        return alamoCode;
    }

    /**
     * @return the country
     */
    public String getCountry() {
        return country;
    }

    /**
     * @return the brand
     */
    public String getBrand() {
        return brand;
    }

    /**
     * @return the vehicleType
     */
    public String getVehicleType() {
        return vehicleType;
    }

    /**
     * @return the vehicleBrand
     */
    public String getVehicleBrand() {
        return vehicleBrand;
    }

    /**
     * @return the vehiclePicture
     */
    public String getVehiclePicture() {
        return vehiclePicture;
    }

    /**
     * @return the pickupLocationName
     */
    public String getPickupLocationName() {
        return pickupLocationName;
    }

    /**
     * @return the pickupLocation
     */
    public String getPickupLocation() {
        return pickupLocation;
    }

    /**
     * @return the returnLocationName
     */
    public String getReturnLocationName() {
        return returnLocationName;
    }

    /**
     * @return the returnLocation
     */
    public String getReturnLocation() {
        return returnLocation;
    }

    /**
     * @return the pickupDate
     */
    public Date getPickupDate() {
        return pickupDate;
    }

    /**
     * @return the returnDate
     */
    public Date getReturnDate() {
        return returnDate;
    }

    /**
     * @return the customerPerfix
     */
    public String getCustomerPerfix() {
        return customerPerfix;
    }

    /**
     * @return the customerName
     */
    public String getCustomerName() {
        return customerName;
    }

    /**
     * @return the customerEmail
     */
    public String getCustomerEmail() {
        return customerEmail;
    }

    /**
     * @return the customerMobile
     */
    public String getCustomerMobile() {
        return customerMobile;
    }

    /**
     * @return the details
     */
    public OrderDetails getDetails() {
        return details;
    }

    /**
     * @return the orderPayType
     */
    public OrderPayType getOrderPayType() {
        return orderPayType;
    }

    /**
     * @return the payPrice
     */
    public int getPayPrice() {
        return payPrice;
    }

    /**
     * @return the actualPayPrice
     */
    public int getActualPayPrice() {
        return actualPayPrice;
    }

    /**
     * @return the costPrice
     */
    public int getCostPrice() {
        return costPrice;
    }
    
    @Transient
    public BigDecimal getBigDecimalCostPrice() {
        return new BigDecimal(this.costPrice).divide(new BigDecimal(100));
    }

    /**
     * @return the totalAmount
     */
    public int getTotalAmount() {
        return totalAmount;
    }

    /**
     * @return the retailAmount
     */
    public int getRetailAmount() {
        return retailAmount;
    }

    /**
     * @return the currencyCode
     */
    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * @return the currentExchangeRate
     */
    public BigDecimal getCurrentExchangeRate() {
        return currentExchangeRate;
    }

    /**
     * @return the agentRate
     */
    public int getAgentRate() {
        return agentRate;
    }

    /**
     * @return the couponId
     */
    public Long getCouponId() {
        return couponId;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the operateEndDate
     */
    public String getOperateEndDate() {
        return operateEndDate;
    }

    /**
     * @return the status
     */
    public OrderStatus getStatus() {
        return status;
    }

    /**
     * @return the payTime
     */
    public Date getPayTime() {
        return payTime;
    }

    /**
     * @return the type
     */
    public PayType getType() {
        return type;
    }

    /**
     * @return the payStatus
     */
    public PayStatus getPayStatus() {
        return payStatus;
    }

    /**
     * @return the agent
     */
    public Agent getAgent() {
        return agent;
    }

    /**
     * @return the rebate
     */
    public int getRebate() {
        return rebate;
    }

    /**
     * @return the invoice
     */
    public Boolean getInvoice() {
        return invoice;
    }

    /**
     * @return the comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * @return the pdfUrl
     */
    public String getPdfUrl() {
        return pdfUrl;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param alamoCode the alamoCode to set
     */
    public void setAlamoCode(String alamoCode) {
        this.alamoCode = alamoCode;
    }

    /**
     * @param country the country to set
     */
    public void setCountry(String country) {
        this.country = country;
    }

    /**
     * @param brand the brand to set
     */
    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * @param vehicleType the vehicleType to set
     */
    public void setVehicleType(String vehicleType) {
        this.vehicleType = vehicleType;
    }

    /**
     * @param vehicleBrand the vehicleBrand to set
     */
    public void setVehicleBrand(String vehicleBrand) {
        this.vehicleBrand = vehicleBrand;
    }

    /**
     * @param vehiclePicture the vehiclePicture to set
     */
    public void setVehiclePicture(String vehiclePicture) {
        this.vehiclePicture = vehiclePicture;
    }

    /**
     * @param pickupLocationName the pickupLocationName to set
     */
    public void setPickupLocationName(String pickupLocationName) {
        this.pickupLocationName = pickupLocationName;
    }

    /**
     * @param pickupLocation the pickupLocation to set
     */
    public void setPickupLocation(String pickupLocation) {
        this.pickupLocation = pickupLocation;
    }

    /**
     * @param returnLocationName the returnLocationName to set
     */
    public void setReturnLocationName(String returnLocationName) {
        this.returnLocationName = returnLocationName;
    }

    /**
     * @param returnLocation the returnLocation to set
     */
    public void setReturnLocation(String returnLocation) {
        this.returnLocation = returnLocation;
    }

    /**
     * @param pickupDate the pickupDate to set
     */
    public void setPickupDate(Date pickupDate) {
        this.pickupDate = pickupDate;
    }

    /**
     * @param returnDate the returnDate to set
     */
    public void setReturnDate(Date returnDate) {
        this.returnDate = returnDate;
    }

    /**
     * @param customerPerfix the customerPerfix to set
     */
    public void setCustomerPerfix(String customerPerfix) {
        this.customerPerfix = customerPerfix;
    }

    /**
     * @param customerName the customerName to set
     */
    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    /**
     * @param customerEmail the customerEmail to set
     */
    public void setCustomerEmail(String customerEmail) {
        this.customerEmail = customerEmail;
    }

    /**
     * @param customerMobile the customerMobile to set
     */
    public void setCustomerMobile(String customerMobile) {
        this.customerMobile = customerMobile;
    }

    /**
     * @param details the details to set
     */
    public void setDetails(OrderDetails details) {
        this.details = details;
    }

    /**
     * @param orderPayType the orderPayType to set
     */
    public void setOrderPayType(OrderPayType orderPayType) {
        this.orderPayType = orderPayType;
    }

    /**
     * @param payPrice the payPrice to set
     */
    public void setPayPrice(int payPrice) {
        this.payPrice = payPrice;
    }

    /**
     * @param actualPayPrice the actualPayPrice to set
     */
    public void setActualPayPrice(int actualPayPrice) {
        this.actualPayPrice = actualPayPrice;
    }

    /**
     * @param costPrice the costPrice to set
     */
    public void setCostPrice(int costPrice) {
        this.costPrice = costPrice;
    }

    /**
     * @param totalAmount the totalAmount to set
     */
    public void setTotalAmount(int totalAmount) {
        this.totalAmount = totalAmount;
    }

    /**
     * @param retailAmount the retailAmount to set
     */
    public void setRetailAmount(int retailAmount) {
        this.retailAmount = retailAmount;
    }

    /**
     * @param currencyCode the currencyCode to set
     */
    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }

    /**
     * @param currentExchangeRate the currentExchangeRate to set
     */
    public void setCurrentExchangeRate(BigDecimal currentExchangeRate) {
        this.currentExchangeRate = currentExchangeRate;
    }

    /**
     * @param agentRate the agentRate to set
     */
    public void setAgentRate(int agentRate) {
        this.agentRate = agentRate;
    }

    /**
     * @param couponId the couponId to set
     */
    public void setCouponId(Long couponId) {
        this.couponId = couponId;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param operateEndDate the operateEndDate to set
     */
    public void setOperateEndDate(String operateEndDate) {
        this.operateEndDate = operateEndDate;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    /**
     * @param payTime the payTime to set
     */
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    /**
     * @param type the type to set
     */
    public void setType(PayType type) {
        this.type = type;
    }

    /**
     * @param payStatus the payStatus to set
     */
    public void setPayStatus(PayStatus payStatus) {
        this.payStatus = payStatus;
    }

    /**
     * @param agent the agent to set
     */
    public void setAgent(Agent agent) {
        this.agent = agent;
    }

    /**
     * @param rebate the rebate to set
     */
    public void setRebate(int rebate) {
        this.rebate = rebate;
    }

    /**
     * @param invoice the invoice to set
     */
    public void setInvoice(Boolean invoice) {
        this.invoice = invoice;
    }

    /**
     * @param comment the comment to set
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     * @param pdfUrl the pdfUrl to set
     */
    public void setPdfUrl(String pdfUrl) {
        this.pdfUrl = pdfUrl;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

	/**
	 * @return the userCouponId
	 */
	public Long getUserCouponId() {
		return userCouponId;
	}

	/**
	 * @param userCouponId the userCouponId to set
	 */
	public void setUserCouponId(Long userCouponId) {
		this.userCouponId = userCouponId;
	}

    public DistributionRewardRecord getDistributionRewardRecord() {
        return distributionRewardRecord;
    }

    public void setDistributionRewardRecord(DistributionRewardRecord distributionRewardRecord) {
        this.distributionRewardRecord = distributionRewardRecord;
    }

    public String getPayPic() {
        return payPic;
    }

    public void setPayPic(String payPic) {
        this.payPic = payPic;
    }

    public Principal getMarkPayOperator() {
        return markPayOperator;
    }

    public void setMarkPayOperator(Principal markPayOperator) {
        this.markPayOperator = markPayOperator;
    }

    public Date getMarkPayTime() {
        return markPayTime;
    }

    public void setMarkPayTime(Date markPayTime) {
        this.markPayTime = markPayTime;
    }

    public Date getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }

    public Date getRefundTime() {
        return refundTime;
    }

    public void setRefundTime(Date refundTime) {
        this.refundTime = refundTime;
    }

    public InvoiceStatus getInvoiceStatus() {
        return invoiceStatus;
    }

    public void setInvoiceStatus(InvoiceStatus invoiceStatus) {
        this.invoiceStatus = invoiceStatus;
    }

    public String getInvoiceQrcodeUrl() {
        return invoiceQrcodeUrl;
    }

    public void setInvoiceQrcodeUrl(String invoiceQrcodeUrl) {
        this.invoiceQrcodeUrl = invoiceQrcodeUrl;
    }

    public String getInvoicePdf() {
        return invoicePdf;
    }

    public void setInvoicePdf(String invoicePdf) {
        this.invoicePdf = invoicePdf;
    }

    public String getRedInvoicePdf() {
        return redInvoicePdf;
    }

    public void setRedInvoicePdf(String redInvoicePdf) {
        this.redInvoicePdf = redInvoicePdf;
    }

    public String getInvoiceOriginalCode() {
        return invoiceOriginalCode;
    }

    public void setInvoiceOriginalCode(String invoiceOriginalCode) {
        this.invoiceOriginalCode = invoiceOriginalCode;
    }

    public String getInvoiceOriginalNumber() {
        return invoiceOriginalNumber;
    }

    public void setInvoiceOriginalNumber(String invoiceOriginalNumber) {
        this.invoiceOriginalNumber = invoiceOriginalNumber;
    }

    public String getInvoiceTitle() {
        return invoiceTitle;
}

    public void setInvoiceTitle(String invoiceTitle) {
        this.invoiceTitle = invoiceTitle;
    }

    public BigDecimal getRetailDollarAmount() {
        return retailDollarAmount;
    }

    public void setRetailDollarAmount(BigDecimal retailDollarAmount) {
        this.retailDollarAmount = retailDollarAmount;
    }
}
